{extend name="public/base" /}

<!-- 关掉头部 -->
{block name="header"}{/block}
<!-- 关掉菜单 -->
{block name="menu"}{/block}

{block name="content"}
<article class="cl pd-20">
	<form action="" method="post" class="form form-horizontal" id="form-admin-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">管理员：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<!--如果用户名是admin,不允许修改-->
				{eq name="$user_info.name" value="admin"}
					<input type="text" class="input-text disabled" value="{$user_info.name}" placeholder="" id="name" name="name" disabled>
				{else /}
				{eq name="$Think.session.user_info.name" value="$user_info.name"}
					<input type="text" class="input-text disabled" value="{$user_info.name}" placeholder="" id="name" name="name" disabled>
				{else /}
					<input type="text" class="input-text" value="{$user_info.name}" placeholder="" id="name" name="name">
				{/eq}
				{/eq}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">新密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" autocomplete="off" value="" placeholder="密码为6位" id="password" name="password">
			</div>
		</div>

		{eq name="$Think.session.user_info.name" value="admin"}
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">启用状态：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
				<select class="select" name="status" size="1">
					{eq name="$user_info.status" value="1"}
						<option value="1" selected>启用</option>
						<option value="0">不启用</option>
					{else /}
						<option value="1">启用</option>
						<option value="0" selected>不启用</option>
					{/eq}
				</select>
				</span>
			</div>
		</div>
		{/eq}
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">邮箱：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="@" name="email" id="email" value="{$user_info.email}">
			</div>
		</div>
		{eq name="$Think.session.user_info.name" value="admin"}
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">角色：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<span class="select-box" style="width:150px;">
					<select class="select" name="role" size="1">
						{eq name="$user_info.role" value="1"}
							<option value="1" selected>超级管理员</option>
							<option value="0">管理员</option>
						{else /}
							<option value="1" >超级管理员</option>
							<option value="0" selected>管理员</option>
						{/eq}
					</select>
				</span>
			</div>
		</div>
		{/eq}

		<!--将当前记录的id做为隐藏域发送到服务器-->
		<input type="hidden" value="{$user_info.id}" name="id">

		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input id="submit" class="btn btn-primary radius disabled" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
{/block}

{block name="js"}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
$(function(){
	$('form').children().change(function(){
		$('#submit').removeClass('disabled');
	})

	$('#submit').on('click',function(event){
		$.ajax({
			type:'POST',
			url:'{:url("user/editUser")}',
			data:$('#form-admin-add').serialize(),
			dataType:'json',
			success:function(data){
				if(data.status==1){
					// alert(data.message);
					parent.location.reload();
				}else{
					alert(data.message);
				}
			}
		})
	})
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
{/block}